<html>
<head><meta charset="utf-8"><title>Interested in contributing · wg-traits · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/index.html">wg-traits</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html">Interested in contributing</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214397740"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214397740" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Fontenot <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214397740">(Oct 23 2020 at 23:43)</a>:</h4>
<p>Hello, I'm interested in helping contribute to Chalk in whatever way I can. Looking at the github issues, would adding TypeFlag information be a good way to start? I'm not totally sure what that entails / where I would be looking in code to do that, so I figured I'd ask.</p>



<a name="214398429"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398429" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398429">(Oct 23 2020 at 23:56)</a>:</h4>
<p>Hi! Yes, adding <code>TypeFlags</code> would be a good place to start :)</p>



<a name="214398434"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398434" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398434">(Oct 23 2020 at 23:56)</a>:</h4>
<p>Let's me get you some links</p>



<a name="214398435"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398435" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398435">(Oct 23 2020 at 23:56)</a>:</h4>
<p>To get you started</p>



<a name="214398456"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398456" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398456">(Oct 23 2020 at 23:57)</a>:</h4>
<p>So, the computation of <code>TypeFlags</code> in rustc is <a href="https://github.com/rust-lang/rust/blob/master/compiler/rustc_middle/src/ty/flags.rs">here</a></p>



<a name="214398509"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398509" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398509">(Oct 23 2020 at 23:58)</a>:</h4>
<p>And they're stored in <code>TyS</code> <a href="https://github.com/rust-lang/rust/blob/7bade6ef730cff83f3591479a98916920f66decd/compiler/rustc_middle/src/ty/mod.rs#L588">here</a></p>



<a name="214398516"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398516" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398516">(Oct 23 2020 at 23:58)</a>:</h4>
<p>In Chalk, that would be <code>TyData</code></p>



<a name="214398742"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398742" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398742">(Oct 24 2020 at 00:02)</a>:</h4>
<p>Then, probably compute the flags in <code>Ty::new</code></p>



<a name="214398807"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214398807" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214398807">(Oct 24 2020 at 00:04)</a>:</h4>
<p>I'll be around if you have any questions or anything :)</p>



<a name="214402687"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214402687" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Fontenot <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214402687">(Oct 24 2020 at 01:32)</a>:</h4>
<p>Ok, so now that I've started working on this, a couple questions: for the TypeFlags struct itself, is there anything different we want in chalk's, or do we want it to be identical to the one in rustc? My other question is with the computations done to get TypeFlags, do we also want to have the same ones as in rustc? If so, what actually is FlagComputation (the rustc struct) actually doing, in general? <span class="user-mention" data-user-id="232957">@Jack Huey</span></p>



<a name="214403761"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214403761" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214403761">(Oct 24 2020 at 01:58)</a>:</h4>
<p>Let me look, but I think the answer is <em>yes</em> we want the same flags as in rustc</p>



<a name="214403771"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214403771" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214403771">(Oct 24 2020 at 01:59)</a>:</h4>
<p>the <code>FlagComputation</code> struct from what I can tell is just the state used when computing flags</p>



<a name="214453998"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214453998" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Fontenot <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214453998">(Oct 24 2020 at 22:50)</a>:</h4>
<p>So I'm starting to understand how rustc computes these flags, to an extent, and something I'm not sure of is how Substitution&lt;I&gt; works in Chalk (it seems to be defined by a macro, but I'm not really sure how to get anything out of it). I think with that knowledge, I can get most of the work with flags handled hopefully quickly, as it seems that a lot of paths in the flag computation involve getting flags from these. Also, I'm not sure how ConstKinds and regions in rustc_middle relate to types in Chalk, if you have any insight there. <span class="user-mention" data-user-id="232957">@Jack Huey</span></p>



<a name="214454632"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214454632" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214454632">(Oct 24 2020 at 23:05)</a>:</h4>
<p>So</p>



<a name="214454644"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214454644" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214454644">(Oct 24 2020 at 23:05)</a>:</h4>
<p>A <code>Substitution</code> basically a list of <code>GenericArg</code>s (one of Ty,Lifetime, or Const)</p>



<a name="214454685"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214454685" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214454685">(Oct 24 2020 at 23:06)</a>:</h4>
<p><code>Region</code>s in rustc are <code>Lifetime</code>s in Chalk</p>



<a name="214454716"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214454716" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214454716">(Oct 24 2020 at 23:07)</a>:</h4>
<p><code>Const</code> in rustc is <code>Const</code> in Chalk, but <code>ConstKind</code> in rustc (which is what variant of const, bound, infer, etc.) is <code>ConstValue</code> in Chalk</p>



<a name="214469681"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214469681" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Fontenot <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214469681">(Oct 25 2020 at 05:15)</a>:</h4>
<p>So, with that I've been able to get a lot of the cases covered, but for a couple, I'm still not entirely sure how they should be handled. In particular, I'm not sure what to do with the Binders on DynTy, BoundVar itself, and for InferenceVar, is there anything we can get out of the TyVariableKind, or does that part of it not really matter? A bit more generally with the flags: in rustc_middle, the flags that end in _PARAM get set when the TyKind matches Param, but chalk doesn't have a Param type. My first guess would be that it involves Adt, but _PARAM flags seem like they can be in lots of places,  so I'm not sure generally where those fall. I also noticed that for FnSig, and Generator and Closure types, rustc_middle calls some additional function on the Substitutions,  (like as_closure()), but Chalk doesn't seem to have an equivalent to that, so what can we do with closure or generator types, besides just iterating over the Substitution list and setting those flags?</p>



<a name="214471736"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214471736" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214471736">(Oct 25 2020 at 06:06)</a>:</h4>
<p>The binders in dyn ty should be treated like and other binder (which I guess means compute the flags for the value inside if we're not tracking escaping variables yet).</p>



<a name="214471944"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214471944" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214471944">(Oct 25 2020 at 06:10)</a>:</h4>
<p>BoundVar doesn't add any flags. _PARAM isn't added for any chalk type.</p>



<a name="214471985"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214471985" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214471985">(Oct 25 2020 at 06:11)</a>:</h4>
<p>For FnSig you can add the subst directly</p>



<a name="214504951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214504951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Fontenot <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214504951">(Oct 25 2020 at 18:35)</a>:</h4>
<p>So I've handled all of the cases that arise from a TyKind now, including handling all the Substitutions, lifetimes, etc, and now my questions are more about other things I need to do for the PR. TypeFlags in rustc_middle has a couple of flags relating to lifetime that FlagComputation in rustc doesn't set, so I haven't done anything with those. Are there cases in chalk where we want to set these (HAS_FREE_REGIONS, HAS_FREE_LOCAL_REGIONS, HAS_RE_LATE_BOUNDS, HAS_ERASED), or do we not need these? </p>
<p>Besides that, how should I go about testing that the computation of flags works as intended? I looked at a couple unit tests, but couldn't figure out how to write some that would handle creating a <code>Ty</code>, as the unit tests I looked at seemed to be related to parsing and lowering, and I'm not sure what pieces I need in a unit test to be able to construct a few <code>Ty</code>s and see if the flags set are what I expect.  The other thing I wanted to check was code formatting, since I know rustc itself uses ./x.py for this, according to the rustc book, but chalk's repo and book don't really say anything.</p>



<a name="214506298"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214506298" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214506298">(Oct 25 2020 at 19:03)</a>:</h4>
<p>I guess that they should be set to match rustc as closely as possible, although a lot of them won't be used by chalk</p>



<a name="214506324"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214506324" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214506324">(Oct 25 2020 at 19:03)</a>:</h4>
<p><a href="https://github.com/rust-lang/rust/blob/3eab21e22d080562dbe85ef440309c03c07becba/compiler/rustc_middle/src/ty/sty.rs#L1689-L1726">https://github.com/rust-lang/rust/blob/3eab21e22d080562dbe85ef440309c03c07becba/compiler/rustc_middle/src/ty/sty.rs#L1689-L1726</a> is the rustc code for lifetimes.</p>



<a name="214508925"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214508925" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214508925">(Oct 25 2020 at 19:59)</a>:</h4>
<p>Of those, <code>HAS_RE_ERASED</code> and <code>HAS_RE_PARAM</code> won't be used</p>



<a name="214508951"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214508951" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Matthew Jasper <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214508951">(Oct 25 2020 at 19:59)</a>:</h4>
<p>Well <code>HAS_RE_ERASED</code> will be used eventually.</p>



<a name="214919657"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214919657" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Christian Fontenot <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214919657">(Oct 29 2020 at 02:20)</a>:</h4>
<p>Ok, so I've made a pullrequest (639) for this. Some things that I'm not sure of would be the couple RE flags that weren't decided on previously (they're there for now, can be removed if needed), and maybe having more tests.</p>



<a name="214921672"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/214921672" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jack Huey <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#214921672">(Oct 29 2020 at 03:01)</a>:</h4>
<p><span class="user-mention" data-user-id="357063">@Christian Fontenot</span> I'll take a look at it tomorrow :)</p>



<a name="215122768"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/144729-wg-traits/topic/Interested%20in%20contributing/near/215122768" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> nikomatsakis <a href="https://rust-lang.github.io/zulip_archive/stream/144729-wg-traits/topic/Interested.20in.20contributing.html#215122768">(Oct 30 2020 at 17:03)</a>:</h4>
<p><span class="user-mention" data-user-id="357063">@Christian Fontenot</span> nice!</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>